package com.leather.express.receiver;

import com.leather.common.result.Result;
import com.leather.common.toolkits.BeanKit;
import com.leather.common.toolkits.MessageKit;
import com.leather.common.vo.MessageVo;
import com.leather.express.config.MQConfig;
import com.leather.express.feignclient.MessageClient;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class QuanQueneReceiver {

    @Autowired
    private MessageClient messageClient;

    @RabbitListener(queues = MQConfig.MESSAGE_QUENE)
    public void receive(String message) {
        MessageVo messageVo = BeanKit.stringToBean(message, MessageVo.class);
        Result result = messageClient.sendMessage(messageVo);
    }

    @RabbitListener(queues = MQConfig.MOBILE_MESSAGE_QUENE)
    public void mobileReceive(String message) {
        String []str = message.split("-");
        String []getAddress = {str[1],str[2],str[3]};
        MessageKit.sendExpressMessage(str[0],getAddress,328950);
    }


}
